{extend name="common:base" /}

{block name="page_title"}{$controllerName}列表{/block}

{block name="content"}
<div class="box">
    <div class="box-header with-border">
        <form method="get" action="{:url('index')}">
        <div class="row">
            {volist name="whereKeys" id="v"}
            {switch $v['type']}
            {case text}
            <div class="col-xs-3">
                <div class="input-group">
                    <span class="input-group-addon">{$v['text']}</span>
                    <input type="text" name="search[{$v['key']}]" class="form-control" placeholder="{$v['text']}" value="{$search[$v['key']]}">
                </div>
            </div>
            {/case}
            {case select}
            <div class="col-xs-3">
                <div class="input-group">
                    <span class="input-group-addon">{$v['text']}</span>
                    <?php
                    $selectData = [];
                    if(!empty($v['type_value'])){ $selectData = $v['type_value']; }
                    elseif(!empty($v['type_value_custom'])){ $selectData = call_user_func('getSelectDropDown',$v['type_value_custom']['table'],$v['type_value_custom']['id'],$v['type_value_custom']['text']); }
                   ?>
                    <select name="search[{$v['key']}]" class="form-control">
                        <option value="">不限</option>
                        {volist name="selectData" id="sd"}
                        <option value="{$sd['id']}" {if($sd['id'] == $search[$v['key']])}selected{/if}>{$sd['text']}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            {/case}
            {/switch}
            {/volist}
            <div class="col-xs-3">
                <div class="row">
                    <div class="col-xs-6">
                        <button type="submit" class="btn btn-block btn-primary">搜索</button>
                    </div>
                    <div class="col-xs-6">
                        <a class="btn btn-block btn-success" href="{:url('index')}">全部</a>
                    </div>
                </div>
            </div>
        </div>
        </form>
    </div>
    <div class="box-body">
        <a href="{:url('add')}" class="btn btn-default">添加管理员</a>
        <hr>
        <table class="table table-hover">
            <tbody>
            <tr>
                <th style="width: 10px">#</th>
                <th>登录用户名</th>
                <th>用户组</th>
                <th>真实姓名</th>
                <th style="width: 30px">状态</th>
                <th style="width: 120px">操作</th>
            </tr>
            {volist name="datas" id="v"}
            <tr>
                <td>{$v['id']}</td>
                <td>{$v['admin_username']}</td>
                <td><?php @(eval('$dongtai=(get_groups('.$v['id'].'));')); echo $dongtai; ?></td>
                <td>{$v['admin_realname']}</td>
                <td>
                    {if condition="$v['admin_open'] eq 1"}
                    <a class="btn btn-block btn-success btn-xs confirm-rst-url-btn" href="{:url('admin/Admin/admin_state',['id'=>$v['id']])}" data-info="你确定要禁用吗？" title="已开启">
                        开启
                    </a>
                    {else/}
                    <a class="btn btn-block btn-danger btn-xs confirm-rst-url-btn" href="{:url('admin/Admin/admin_state',['id'=>$v['id']])}" data-info="你确定要开启吗？" title="已禁用">
                        禁用
                    </a>
                    {/if}
                </td>
                <td>
                    <a href="{:url('edit',array('id'=>$v['id']))}">编辑</a>
                    <a class="confirm-rst-url-btn" href="{:url('del',array('id'=>$v['id']))}" data-info="你确定要删除吗？">删除</a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </div>
    <div class="box-footer clearfix">
        <div id="page1" class="pull-right"></div>
    </div>
</div>
{/block}

{block name="script"}
<script>
    var totalPages = {$totalPages};
    var pageIndex = {$pageIndex};
    laypage({
        cont: 'page1', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
        pages: totalPages, //通过后台拿到的总页数
        curr: pageIndex, //当前页
        skip: true, //是否开启跳页
        jump: function(obj, first){ //触发分页后的回调
            if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                location.href = "{$pageUrl|raw}" +  "&p=" + obj.curr
            }
        }
    });
</script>
{/block}